package p2Greep;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class tokenBean implements WritableComparable<tokenBean> {

    private String uid;           //用户编号
    private String mid;           //商户编号
    private String cid;           //优惠券编号
    private String drate;         //折扣率
    private String rdate;         //接收日期
    private String date;          //日期


    public tokenBean() {
    }

    @Override
    public int compareTo(tokenBean o) {
        return 1;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeChars(uid+',');
        dataOutput.writeChars(mid+',');
        dataOutput.writeChars(cid+',');
        dataOutput.writeChars(drate+',');
        dataOutput.writeChars(rdate+',');
        dataOutput.writeChars(date);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        String ss;
        ss=dataInput.readLine();
        String[] fields=ss.split(",");
        uid=fields[0];
        mid=fields[1];
        cid=fields[2];
        drate=fields[3];
        rdate=fields[4];
        date=fields[5];
    }

    @Override
    public String toString() {
        return  uid+","+mid+","+cid+","+drate+","+rdate+","+date;
    }

    public String getUid() {
        return uid;
    }

    public void setUid(String uid) {
        this.uid = uid;
    }

    public String getMid() {
        return mid;
    }

    public void setMid(String mid) {
        this.mid = mid;
    }

    public String getCid() {
        return cid;
    }

    public void setCid(String cid) {
        this.cid = cid;
    }

    public String getDrate() {
        return drate;
    }

    public void setDrate(String drate) {
        this.drate = drate;
    }

    public String getRdate() {
        return rdate;
    }

    public void setRdate(String rdate) {
        this.rdate = rdate;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public tokenBean(String uid, String mid, String cid, String drate, String rdate, String date) {
        this.uid = uid;
        this.mid = mid;
        this.cid = cid;
        this.drate = drate;
        this.rdate = rdate;
        this.date = date;
    }

    public void set(String uid,String mid,String cid,String drate,String rdate,String date){
        this.uid = uid;
        this.mid = mid;
        this.cid = cid;
        this.drate = drate;
        this.rdate = rdate;
        this.date = date;
    }
}
